/*
 * @Author: aggfb 714740235@qq.com
 * @Date: 2024-05-02 17:30:33
 * @LastEditors: aggfb 714740235@qq.com
 * @LastEditTime: 2025-01-12 01:40:01
 * @FilePath: \label_rack_control\firmware\model\crc\crc16.h
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%A
 */
#ifndef __E32_900_H
#define __E32_900_H

#include <stdint.h>

struct e32_900_register
{
    uint8_t head; // 00H
    uint8_t add_h; // 01H 设备地址
    uint8_t add_l; // 02H
    struct sped   // 03H 
    {
        uint8_t parity_bit:2; /* 串口校验位 */
        uint8_t air_rate:3; /* 空中速率 */
        uint8_t baud:3; /* 串口波特率 */
    }sped;
    struct chan   // 04H 
    {
        uint8_t reseved:3; /* 预留 */
        uint8_t channel:5; /* 信道 */
    }chan;
    struct option   // 05H 
    {
        uint8_t modbus:1; /* 透明/定点传输 */
        uint8_t io_mode:1; /* 默认1 */
        uint8_t wake_up:3; /* 唤醒时间 */
        uint8_t fec:1;/* 默认1 */
        uint8_t power:2; /* 发送功率 默认:30db */
    }option;
};

enum mode_type{
    LORA_MODE_NORMAL, 
    LORA_MODE_WOR,
    LORA_MODE_CONFIG,
    LORA_MODE_SLEEP,
    LORA_MODE_TOTAL,
};

enum cmd_type{
    LORA_CMD_WRITE_REG = 0xc0, 
    LORA_CMD_READ_REG = 0xc1,
    LORA_CMD_WRITE_TEMP_RGE = 0xc2,
    LORA_CMD_WIRELESS_REG = 0xcf,
};

enum reg_type{
    REG_TYPE_HEAD, 
    REG_TYPE_ADD_H, 
    REG_TYPE_ADD_L,
    REG_TYPE_ADD_SPED,
    REG_TYPE_ADD_CHAN,
    REG_TYPE_ADD_OPTION,
};

struct lora_e32_900 {
    uint8_t flag_config;
    struct e32_900_register config_reg;
    struct e32_900_register real_reg;
};

extern int16_t e32_900_config(void); // 配置 lora模块

#endif
